using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Fan.Dongping.Common;
using System.IO;
using Fan.Dongping.BusinessRules;

public partial class Comm_Attach : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //byte[] body = dr["fileBody"] as byte[];  
        //string path = Config.Instance.DirectoryOfUpload + (Request.Params["F"]);
        string path = SystemSetting.DocRootPath() + "\\" + (Request.Params["F"]);
        FileInfo fin = new FileInfo(path);

        if (fin.Exists == false)
        {
            Response.Write("Sorry,This file is not exist in directory.");
            Response.End();
        }

        Response.Clear();
        Response.ClearHeaders();
        Response.Buffer = false;
        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("Connection", "keep-alive");
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Path.GetFileName(path), System.Text.Encoding.UTF8));
        Response.AppendHeader("Content-Length", fin.Length.ToString());

        Response.WriteFile(path);
    }
}
